package com.xcm.model;

import java.io.Serializable;

import com.xcm.constant.ClientConstant;

/**
 * <p>Title: OperationResult</p>  
 * <p>Description: used for returning this type of object to client in ajax request circumstance</p>  
 * @author huangf 
 * @date 2018年4月19日
 */
public class OperationResult<T> implements Serializable {
	
	private static final long serialVersionUID = 3779231221394313342L;
	
	private int code;
	
	private String msg;
	
	private T data;

	public OperationResult() {
	}

	public OperationResult( String msg, T data ) {
		this.msg = msg;
		this.data = data;
	}
	
	public OperationResult( int code, String msg,T data ) {
		this( msg, data );
		this.code = code;
	}

	public OperationResult(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	public static OperationResult<Object> newSystemErrorOperationResult(){
		return new OperationResult<Object>(ClientConstant.CODE_SYSTEM_ERROR, ClientConstant.MSG_FAIL_OR_SYSTEM_ERROR);
	}
}
